package com.yq.activemq.p2p;

import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

public class AppProducer {

    private static final String url = ActiveMQConnection.DEFAULT_BROKER_URL;
    private static final String queueName = "queue-test";

    public static void main(String[] args) throws JMSException {
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
        Connection connection = connectionFactory.createConnection();
        connection.start();

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Queue queue = session.createQueue(queueName);
        MessageProducer producer = session.createProducer(queue);


        for (int i = 0; i < 10; i++) {
            TextMessage textMessage = session.createTextMessage("test " + i);
            producer.send(textMessage);
        }
        connection.close();
    }
}
